home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / vla / viewtga / clsub.asm < prev    next >
Assembly Source File  |  1994-01-10  |  2KB  |  97 lines

  1.     IDEAL
  2.     MODEL SMALL
  3.     STACK 200h
  4.     p386n
  5.  
  6. ──────────────────────────────────────────────────────────────────────
  7.  
  8. CODESEG
  9. ──────────────────────────────────────────────────────────────────────
  10.  
  11. PUBLIC  GetCommandLine
  12.  
  13. InputLength dw  0
  14. FileNameOff dw  0       ;offset from CS: to filename
  15.  
  16. ──────────────────────────────────────────────────────────────────────
  17.  
  18.     ┌────────────────────────────────────────────────
  19.     ; File:     CLSUB.ASM
  20.     ;
  21.     ; ┌────────────────────────────────────────────────
  22.     ; Proc:     GetCommandLine
  23.     ; 
  24.     ; Entry: 
  25.     ;
  26.     ;   ES      = PSP SEG 
  27.     ;   CS:DX   = pointer to filename area
  28.     ;   CS:BX   = pointer to 5 byte 0 terminating Extension to add
  29.     ;
  30.     ; Return: 
  31.     ;
  32.     ;   AX      = length of command line
  33.     ; └────────────────────────────────────────────────
  34.     ;
  35.     └────────────────────────────────────────────────
  36.  
  37.  
  38. PROC GetCommandLine
  39.     pusha
  40.     push    es                      ;push the PSP seg
  41.     pop     ds                      ;pop it into DS
  42.     push    bx                      ;save offset to Extension
  43.     
  44.     mov     [cs:FileNameOff],DX
  45.     mov     [cs:InputLength],0      ;reset length read
  46.  
  47.     mov     si,128
  48.     lodsb
  49.     xor     cx,cx
  50.     mov     cl,al
  51.     or      cx,cx
  52.     je      @@CapDone
  53.     
  54.     mov     ax,cs
  55.     mov     es,ax
  56.     mov     di,[cs:FileNameOff]
  57.  
  58.     xor     bl,bl
  59.  
  60. @@NoSpace:
  61.     or      cx,cx
  62.     je      @@DoneName
  63.     dec     cx
  64.     lodsb
  65.     or      al,al
  66.     je      @@DoneName   
  67.     
  68.     cmp     al,' '
  69.     jbe     @@NoSpace
  70.     
  71.     stosb 
  72.     inc     bl
  73.     cmp     bl,8
  74.     jb      @@NoSpace
  75.  
  76. @@DoneName:
  77.     xor     bh,bh
  78.     mov     [cs:InputLength],bx
  79.     mov     ax,cs
  80.     mov     ds,ax
  81.     
  82.     pop     si
  83.     push    si
  84.     
  85.     mov     cx,5                        ;copies extension to end of filename
  86.     rep     movsb
  87.  
  88. @@Capdone:
  89.     pop     si
  90.     popa
  91.     mov     ax,[cs:InputLength]         ;return # of bytes 
  92.     ret
  93. ENDP GetCommandLine
  94.  
  95.     END
  96.  
  97.